home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / basic / ace24dist.lha / ace24.lha / include / libraries / realtime.h < prev    next >
C/C++ Source or Header  |  1996-09-10  |  8KB  |  250 lines

  1. #ifndef LIBRARIES_REALTIME_H
  2. #define LIBRARIES_REALTIME_H
  3. /*
  4. ** realtime.h for ACE Basic
  5. **
  6. ** Note: Translated to ACE by ConvertC2ACE
  7. **       @ MapMeadow Software, Nils Sjoholm
  8. **
  9. **
  10. ** Date: 09/01/95
  11. **
  12. **
  13. */
  14.  
  15. /*
  16. ** This are the StructPointer defines for realtime.h
  17. */
  18. #ifndef ConductorPtr
  19. #define ConductorPtr ADDRESS
  20. #endif
  21. #ifndef PlayerPtr
  22. #define PlayerPtr ADDRESS
  23. #endif
  24. #ifndef RealTimeBasePtr
  25. #define RealTimeBasePtr ADDRESS
  26. #endif
  27. #ifndef pmStatePtr
  28. #define pmStatePtr ADDRESS
  29. #endif
  30. #ifndef pmTimePtr
  31. #define pmTimePtr ADDRESS
  32. #endif
  33. /*
  34. ** End of StructPointer defines for realtime.h
  35. */
  36.  
  37.  
  38. /*****************************************************************************/
  39.  
  40.  
  41. #ifndef EXEC_TYPES_H
  42. #include <exec/types.h>
  43. #endif
  44.  
  45. #ifndef EXEC_LISTS_H
  46. #include <exec/lists.h>
  47. #endif
  48.  
  49. #ifndef EXEC_LIBRARIES_H
  50. #include <exec/libraries.h>
  51. #endif
  52.  
  53. #ifndef UTILITY_TAGITEM_H
  54. #include <utility/tagitem.h>
  55. #endif
  56.  
  57. #ifndef UTILITY_HOOKS_H
  58. #include <utility/hooks.h>
  59. #endif
  60.  
  61.  
  62. /*****************************************************************************/
  63.  
  64.  
  65. /* realtime.library's idea of time is based on a clock which emits a pulse
  66.  * 1200 times a second (1.2kHz). All time values maintained by realtime.library
  67.  * are based on this number. For example,  the field RealTimeBase->rtb_Time
  68.  * expresses an amount of time equivalent to (RealTimeBase->rtb_Time/TICK_FREQ)
  69.  * seconds.
  70.  */
  71. #define TICK_FREQ 1200
  72.  
  73.  
  74. /*****************************************************************************/
  75.  
  76.  
  77. /* Each Conductor represents a group of applications which wish to remain
  78.  * synchronized together.
  79.  *
  80.  * This structure must only be allocated by realtime.library and is
  81.  * READ-ONLY!
  82.  */
  83. STRUCT Conductor
  84.  
  85.     Node cdt_Link 
  86.     SHORTINT      cdt_Reserved0 
  87.     MinList cdt_Players       /* this conductor's players      */
  88.     LONGINT      cdt_ClockTime     /* current time of this sequence */
  89.     LONGINT      cdt_StartTime     /* start time of this sequence   */
  90.     LONGINT      cdt_ExternalTime      /* time from external unit   */
  91.     LONGINT      cdt_MaxExternalTime   /* upper limit on sync'd time    */
  92.     LONGINT      cdt_Metronome     /* MetricTime highest pri node   */
  93.     SHORTINT      cdt_Reserved1 
  94.     SHORTINT      cdt_Flags         /* conductor flags       */
  95.     BYTE       cdt_State         /* playing or stopped        */
  96. END STRUCT 
  97.  
  98. /* Flag bits for Conductor.cdt_Flags */
  99. #define CONDUCTF_EXTERNAL (1)   /* clock is externally driven */
  100. #define CONDUCTF_GOTTICK  (2)   /* received 1st external tick */
  101. #define CONDUCTF_METROSET (4)   /* cdt_Metronome filled in    */
  102. #define CONDUCTF_PRIVATE  (8)   /* conductor is private   */
  103.  
  104. #define CONDUCTB_EXTERNAL 0
  105. #define CONDUCTB_GOTTICK  1
  106. #define CONDUCTB_METROSET 2
  107. #define CONDUCTB_PRIVATE  3
  108.  
  109. /* constants for Conductor.cdt_State and SetConductorState() */
  110. #define CONDSTATE_STOPPED     0   /* clock is stopped          */
  111. #define CONDSTATE_PAUSED      1   /* clock is paused           */
  112. #define CONDSTATE_LOCATE      2   /* go to 'running' when ready    */
  113. #define CONDSTATE_RUNNING     3   /* run clock NOW         */
  114.  
  115. /* These do not actually exist as Conductor states,  but are used as additional
  116.  * arguments to SetConductorState()
  117.  */
  118. #define CONDSTATE_METRIC     -1   /* ask high node to locate       */
  119. #define CONDSTATE_SHUTTLE    -2   /* time changing but not running */
  120. #define CONDSTATE_LOCATE_SET -3   /* maestro done locating     */
  121.  
  122.  
  123. /*****************************************************************************/
  124.  
  125.  
  126. /* The Player is the connection between a Conductor and an application.
  127.  *
  128.  * This structure must only be allocated by realtime.library and is
  129.  * READ-ONLY!
  130.  */
  131. STRUCT Player
  132.  
  133.     Node pl_Link 
  134.     BYTE          pl_Reserved0 
  135.     BYTE          pl_Reserved1 
  136.     HookPtr  pl_Hook        /* player's hook function   */
  137.     ConductorPtr  pl_Source      /* pointer to parent context    */
  138.     TaskPtr  pl_Task        /* task to signal for alarm     */
  139.     LONGINT          pl_MetricTime      /* current time in app's metric */
  140.     LONGINT          pl_AlarmTime   /* time to wake up      */
  141.     ADDRESS   pl_UserData    /* for application use  */
  142.     SHORTINT         pl_PlayerID    /* for application use  */
  143.     SHORTINT         pl_Flags   /* general Player flags     */
  144. END STRUCT 
  145.  
  146. /* Flag bits for Player.pl_Flags */
  147. #define PLAYERF_READY     (1)   /* player is ready to go!        */
  148. #define PLAYERF_ALARMSET  (2)   /* alarm is set          */
  149. #define PLAYERF_QUIET     (4)   /* a dummy player,  used for sync */
  150. #define PLAYERF_CONDUCTED (8)   /* give me metered time      */
  151. #define PLAYERF_EXTSYNC   (16)   /* granted external sync     */
  152.  
  153. #define PLAYERB_READY     0
  154. #define PLAYERB_ALARMSET  1
  155. #define PLAYERB_QUIET     2
  156. #define PLAYERB_CONDUCTED 3
  157. #define PLAYERB_EXTSYNC   4
  158.  
  159.  
  160. /*****************************************************************************/
  161.  
  162.  
  163. /* Tags for CreatePlayer(),  SetPlayerAttrs(),  and GetPlayerAttrs() */
  164. #define PLAYER_Base     (TAG_USER+64)
  165. #define PLAYER_Hook     (PLAYER_Base+1)   /* set address of hook function */
  166. #define PLAYER_Name     (PLAYER_Base+2)   /* name of player       */
  167. #define PLAYER_Priority     (PLAYER_Base+3)   /* priority of player       */
  168. #define PLAYER_Conductor    (PLAYER_Base+4)   /* set conductor for player     */
  169. #define PLAYER_Ready        (PLAYER_Base+5)   /* the "ready" flag         */
  170. #define PLAYER_AlarmTime    (PLAYER_Base+12)  /* alarm time (sets PLAYERF_ALARMSET) */
  171. #define PLAYER_Alarm        (PLAYER_Base+13)  /* sets/clears PLAYERF_ALARMSET flag  */
  172. #define PLAYER_AlarmSigTask (PLAYER_Base+6)   /* task to signal for alarm/notify    */
  173. #define PLAYER_AlarmSigBit  (PLAYER_Base+8)   /* signal bit for alarm (or -1) */
  174. #define PLAYER_Conducted    (PLAYER_Base+7)   /* sets/clears PLAYERF_CONDUCTED flag   */
  175. #define PLAYER_Quiet        (PLAYER_Base+9)   /* don't process time thru this */
  176. #define PLAYER_UserData     (PLAYER_Base+10)
  177. #define PLAYER_ID       (PLAYER_Base+11)
  178. #define PLAYER_ExtSync      (PLAYER_Base+14)  /* attempt/release to ext sync  */
  179. #define PLAYER_ErrorCode    (PLAYER_Base+15)  /* error return value       */
  180.  
  181.  
  182. /*****************************************************************************/
  183.  
  184.  
  185. /* Method types for messages sent via a Player's hook */
  186. #define PM_TICK     0
  187. #define PM_STATE    1
  188. #define PM_POSITION 2
  189. #define PM_SHUTTLE  3
  190.  
  191. /* used for PM_TICK,  PM_POSITION and PM_SHUTTLE methods */
  192. STRUCT pmTime
  193.  
  194.     LONGINT pmt_Method         /* PM_TICK,  PM_POSITION,  or PM_SHUTTLE */
  195.     LONGINT pmt_Time 
  196. END STRUCT 
  197.  
  198. /* used for the PM_STATE method */
  199. STRUCT pmState
  200.  
  201.     LONGINT pms_Method         /* PM_STATE */
  202.     LONGINT pms_OldState 
  203. END STRUCT 
  204.  
  205.  
  206. /*****************************************************************************/
  207.  
  208.  
  209. /* Possible lock types for LockRealTime() */
  210. #define RT_CONDUCTORS 0   /* conductor list */
  211.  
  212.  
  213. /*****************************************************************************/
  214.  
  215.  
  216. /* realtime.library error codes */
  217. #define RTE_NOMEMORY    801   /* memory allocation failed      */
  218. #define RTE_NOCONDUCTOR 802   /* player needs a conductor      */
  219. #define RTE_NOTIMER 803   /* timer (CIA) allocation failed */
  220. #define RTE_PLAYING 804   /* can't shuttle while playing   */
  221.  
  222.  
  223. /*****************************************************************************/
  224.  
  225.  
  226. /* OpenLibrary("realtime.library", 0) returns a pointer to this structure.
  227.  * All fields are READ-ONLY.
  228.  */
  229. STRUCT RealTimeBase
  230.  
  231.     _Library rtb_LibNode 
  232.     STRING rtb_Reserved0 SIZE 2  
  233.  
  234.     LONGINT      rtb_Time          /* current time                 */
  235.     LONGINT      rtb_TimeFrac      /* fixed-point fraction part of time    */
  236.     SHORTINT      rtb_Reserved1 
  237.     SHORTINT       rtb_TickErr       /* nanosecond error from ideal Tick     */
  238. END STRUCT                    /* length to real tick length       */
  239.  
  240. /* Actual tick length is: 1/TICK_FREQ + rtb_TickErr/1e9 */
  241.  
  242. #define RealTime_TickErr_Min -705
  243. #define RealTime_TickErr_Max  705
  244.  
  245.  
  246. /*****************************************************************************/
  247.  
  248.  
  249. #endif /* LIBRARIES_REALTIME_H */
  250.